css2<- read.csv("css05_cv.csv")

css2$part<- css2$cash + css2$vouchers
css2$part[css2$part==2]<-1
css2$part<- css2$part*100

css2$voucher_yr<-0
css2$voucher_yr[css2$elec_year>2016]<-1
css2$republican<- 0
css2$republican[css2$party=="Democratic"]<- 0
css2$republican[css2$party=="Republican"]<- 1
css2$republican[css2$party=="Non-Partisan"]<- 0
css2$iswhiteperson<- 0
css2$iswhiteperson[css2$race=="European"]<- 1
css2$iswhiteperson[is.na(css2$race)]<- NA
css2$isnonwhiteperson<- 1-css2$iswhiteperson
css2$income<- as.numeric(paste0(substr(css2$income,2,nchar(css2$income))))
css2$income_perc<- ceiling(ecdf(css2$income)(css2$income)*10)
css2$amount<- css2$cash_amt + css2$vouchers_amt


css3<- subset(css2, css2$elec_year<2021)
css3$nw_gen<-0
css3$nw_gen[css3$cc_seat %in% 
              c("SEATTLE CITY CNCL DIST 5","SEATTLE CITY CNCL DIST 4","SEATTLE CITY CNCL DIST 2") & css3$elec_year ==2017]<-1
css3$nw_gen[css3$cc_seat %in% 
              c("SEATTLE CITY CNCL DIST 2","SEATTLE CITY CNCL DIST 3","SEATTLE CITY CNCL DIST 5") & css3$elec_year ==2015]<-1

css3$newvar<- paste0(css3$nw_gen, css3$isnonwhiteperson)
css3<- subset(css3, !is.na(css3$isnonwhiteperson))
qqq1_3<- felm(part~newvar*voucher_yr|as.factor(id)+as.factor(elec_year)|0|0 , data=css3)
summary(qqq1_3, robust=T) #column 1



css3<- css2
css3$nw_gen<-0
css3$nw_gen[css3$cc_seat %in% 
              c("SEATTLE CITY CNCL DIST 5","SEATTLE CITY CNCL DIST 4","SEATTLE CITY CNCL DIST 2") & css3$elec_year ==2017]<-1
css3$nw_gen[css3$cc_seat %in% 
              c("SEATTLE CITY CNCL DIST 2","SEATTLE CITY CNCL DIST 3","SEATTLE CITY CNCL DIST 5") & css3$elec_year ==2015]<-1
css3$nw_gen[css3$elec_year==2021]<-1

css3$newvar<- paste0(css3$nw_gen, css3$isnonwhiteperson)
css3<- subset(css3, !is.na(css3$isnonwhiteperson))

qqq1_3a<- felm(part~newvar*voucher_yr|as.factor(id)+as.factor(elec_year)|0|0 , data=css3)
summary(qqq1_3a, robust=T) #column 2
#stargazer(qqq1_3,qqq1_3a,df=F, no.space = T,single.row = F, title = "", dep.var.labels = c("Likelihood of donating"), digits = 2,omit.table.layout = "n",star.cutoffs = NA)

